package servlet;

import hadoop.WordCount;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @auther 郭天凌
 * @date 2022/3/11
 */
@WebServlet("/demo3")
public class servledemo3 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String srcPath =  req.getParameter("srcpath");
        String destPath = req.getParameter("destpath");


        WordCount wordCount=new WordCount();
        String  result = "";
        try {
            result  =  wordCount.wc(srcPath,destPath);
        }catch (Exception e){
            e.printStackTrace();
        }


        resp.setContentType("text/html;charset=utf-8");
        PrintWriter pw =  resp.getWriter();
        pw.write(result);

    }
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req,resp);
    }




}
